package com.ketai.web;

import com.ketai.service.CheckNumberService;
import com.ketai.service.impl.CheckNumberServiceImpl;
import com.ketai.util.SendUtil;
import com.ketai.vo.StatisticsVo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author:胡远博
 * @Description:
 * @Date:Create In 2022-08-11 2:17
 **/
@WebServlet("/checkNumberServlet")
public class CheckNumberServlet extends HttpServlet {
    CheckNumberService checkNumberService = new CheckNumberServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=UTF-8");
        String opr = req.getParameter("opr");
        if ("userCount".equals(opr)) {
            int count = checkNumberService.selectUserCount();
            SendUtil.Sendjson(resp, count);
        }
        if ("organCount".equals(opr)) {
            int count = checkNumberService.selectOrganCount();
            SendUtil.Sendjson(resp, count);
        }
        if ("activiCount".equals(opr)) {
            int count = checkNumberService.selectActivityCount();
            SendUtil.Sendjson(resp, count);
        }
        //分类汇总饼状图
        if ("subtotal".equals(opr)) {
            List list = checkNumberService.selectSubtotal();
            SendUtil.Sendjson(resp, list);
        }
        //    信息统计表格
        if ("infototal".equals(opr)) {
            List<StatisticsVo> statistics = checkNumberService.getStatistics();
            SendUtil.Sendjson(resp, statistics);

        }
    }
}

